<template>
 <div id="main">
   <div id="content">
     <div class="panel">
       <div class="header">
         <ul class="breadcrumb">
           <li><a href="/">主页</a><span class="divider">/</span></li>
           <li class="active">API</li>
         </ul>
       </div>
       <div class="inner topic">
         <div class="topic_content">
           <div class="markdown-text"><h3>主题</h3>
             <h4>get /topics 主题首页</h4>
             <p>接收 get 参数</p>
             <ul>
               <li>page <code>Number</code> 页数</li>
               <li>tab <code>String</code> 主题分类</li>
               <li>limit <code>Number</code> 每一页的主题数量</li>
               <li>mdrender <code>String</code> 当为 <code>false</code> 时，不渲染。默认为 <code>true</code></li>
             </ul>
             <p>示例：<a href="/api/v1/topics" target="_blank">/api/v1/topics</a></p>
             <h4>get /topic/:id 主题详情</h4>
             <p>接收 get 参数</p>
             <ul>
               <li>mdrender <code>String</code> 当为 <code>false</code> 时，不渲染。默认为 <code>true</code></li>
             </ul>
             <p>示例：<a href="/api/v1/topic/5433d5e4e737cbe96dcef312" target="_blank">/api/v1/topic/5433d5e4e737cbe96dcef312</a></p>
             <h4>post /topics 新建主题</h4>
             <p>接收 post 参数</p>
             <ul>
               <li>title <code>String</code> 标题</li>
               <li>tab <code>String</code> 目前有 <code>ask</code> <code>share</code> <code>job</code></li>
               <li>content <code>String</code> 主体内容</li>
             </ul>
             <p>返回值示例</p>
             <pre class="prettyprint language-js"><code class="hljs javascript"><span class="pun">{</span><span class="pln">success</span><span class="pun">:</span><span class="pln"> </span><span class="kwd"><span class="hljs-literal">true</span></span><span class="pun">,</span><span class="pln"> topic_id</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">'5433d5e4e737cbe96dcef312'</span></span><span class="pun">}</span></code></pre><h4>post /topic/collect 收藏主题</h4>
             <p>接收 post 参数</p>
             <ul>
               <li>accesstoken <code>String</code> 用户的 accessToken</li>
               <li>topic_id <code>String</code> 被收藏的主题id</li>
             </ul>
             <p>返回值示例</p>
             <pre class="prettyprint language-js"><code class="hljs javascript"><span class="pun">{</span><span class="pln">success</span><span class="pun">:</span><span class="pln"> </span><span class="kwd"><span class="hljs-literal">true</span></span><span class="pun">}</span></code></pre><h4>post /topic/de_collect 取消收藏</h4>
             <p>接收 post 参数</p>
             <ul>
               <li>accesstoken <code>String</code> 用户的 accessToken</li>
               <li>topic_id <code>String</code> 被取消收藏的主题id</li>
             </ul>
             <p>返回值示例</p>
             <pre class="prettyprint language-js"><code class="hljs javascript"><span class="pun">{</span><span class="pln">success</span><span class="pun">:</span><span class="pln"> </span><span class="kwd"><span class="hljs-literal">true</span></span><span class="pun">}</span></code></pre><h3>评论</h3>
             <h4>post /topic/:topic_id/replies 新建评论</h4>
             <p>接收 post 参数</p>
             <ul>
               <li>accesstoken <code>String</code> 用户的 accessToken</li>
               <li>content <code>String</code> 评论的主体</li>
               <li>reply_id <code>String</code> 如果这个评论是对另一个评论的回复，请务必带上此字段。这样前端就可以构建出评论线索图。</li>
             </ul>
             <p>返回值示例</p>
             <pre class="prettyprint language-js"><code class="hljs javascript"><span class="pun">{</span><span class="pln">success</span><span class="pun">:</span><span class="pln"> </span><span class="kwd"><span class="hljs-literal">true</span></span><span class="pun">,</span><span class="pln"> reply_id</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">'5433d5e4e737cbe96dcef312'</span></span><span class="pun">}</span></code></pre><h4>post /reply/:reply_id/ups 为评论点赞</h4>
             <p>接受 post 参数</p>
             <ul>
               <li>accesstoken <code>String</code></li>
             </ul>
             <p>接口会自动判断用户是否已点赞，如果否，则点赞；如果是，则取消点赞。点赞的动作反应在返回数据的 <code>action</code> 字段中，<code>up</code> or <code>down</code>。</p>
             <p>返回值示例</p>
             <pre class="prettyprint language-js"><code class="hljs javascript"><span class="pun">{</span><span class="str"><span class="hljs-string">"success"</span></span><span class="pun">:</span><span class="pln"> </span><span class="kwd"><span class="hljs-literal">true</span></span><span class="pun">,</span><span class="pln"> </span><span class="str"><span class="hljs-string">"action"</span></span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"down"</span></span><span class="pun">}</span></code></pre><h3>用户</h3>
             <h4>get /user/:loginname 用户详情</h4>
             <p>示例：<a href="/api/v1/user/DongHongfei" target="_blank">/api/v1/user/DongHongfei</a></p>
             <h4>post /accesstoken 验证 accessToken 的正确性</h4>
             <p>接收 post 参数</p>
             <ul>
               <li>accesstoken <code>String</code> 用户的 accessToken</li>
             </ul>
             <p>如果成功匹配上用户，返回成功信息。否则 403。</p>
             <p>返回值示例</p>
             <pre class="prettyprint language-js"><code class="hljs javascript"><span class="pun">{</span><span class="pln">success</span><span class="pun">:</span><span class="pln"> </span><span class="kwd"><span class="hljs-literal">true</span></span><span class="pun">,</span><span class="pln"> loginname</span><span class="pun">:</span><span class="pln"> req</span><span class="pun">.</span><span class="pln">user</span><span class="pun">.</span><span class="pln">loginname</span><span class="pun">}</span></code></pre><h3>消息通知</h3>
             <h4>get /message/count 获取未读消息数</h4>
             <p>接收 get 参数</p>
             <ul>
               <li>accesstoken <code>String</code></li>
             </ul>
             <p>返回值示例</p>
             <pre class="prettyprint language-js"><code class="hljs javascript"><span class="pun">{</span><span class="pln"> data</span><span class="pun">:</span><span class="pln"> </span><span class="lit"><span class="hljs-number">3</span></span><span class="pln"> </span><span class="pun">}</span></code></pre><h4>get /messages 获取已读和未读消息</h4>
             <p>接收 get 参数</p>
             <ul>
               <li>accesstoken <code>String</code></li>
             </ul>
             <p>返回值示例</p>
             <pre class="prettyprint language-js"><code class="hljs javascript"><span class="pun">{</span><span class="pln">
  data</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
    has_read_messages</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[],</span><span class="pln">
    hasnot_read_messages</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln">
      </span><span class="pun">{</span><span class="pln">
        id</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"543fb7abae523bbc80412b26"</span></span><span class="pun">,</span><span class="pln">
        type</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"at"</span></span><span class="pun">,</span><span class="pln">
        has_read</span><span class="pun">:</span><span class="pln"> </span><span class="kwd"><span class="hljs-literal">false</span></span><span class="pun">,</span><span class="pln">
        author</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
          loginname</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"DongHongfei"</span></span><span class="pun">,</span><span class="pln">
          avatar_url</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"https://avatars.githubusercontent.com/u/5700428?v=3"</span></span><span class="pln">
        </span><span class="pun">},</span><span class="pln">
        topic</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
          id</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"542d6ecb9ecb3db94b2b3d0f"</span></span><span class="pun">,</span><span class="pln">
          title</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"adfadfadfasdf"</span></span><span class="pun">,</span><span class="pln">
          last_reply_at</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"2014-10-18T07:47:22.563Z"</span></span><span class="pln">
        </span><span class="pun">},</span><span class="pln">
        reply</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
          id</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"543fb7abae523bbc80412b24"</span></span><span class="pun">,</span><span class="pln">
          content</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"[@DongHongfei](/user/DongHongfei) 哼哼哈嘿"</span></span><span class="pun">,</span><span class="pln">
          ups</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="pun">],</span><span class="pln">
          create_at</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">"2014-10-16T12:18:51.566Z"</span></span><span class="pln">
          </span><span class="pun">}</span><span class="pln">
        </span><span class="pun">},</span><span class="pln">
    </span><span class="pun">...</span><span class="pln">
    </span><span class="pun">]</span><span class="pln">
  </span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span></code></pre><h4>post /message/mark_all 标记全部已读</h4>
             <p>接收 post 参数</p>
             <ul>
               <li>accesstoken <code>String</code></li>
             </ul>
             <p>返回值示例</p>
             <pre class="prettyprint language-js"><code class="hljs javascript"><span class="pun">{</span><span class="pln"> success</span><span class="pun">:</span><span class="pln"> </span><span class="kwd"><span class="hljs-literal">true</span></span><span class="pun">,</span><span class="pln">
  marked_msgs</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> id</span><span class="pun">:</span><span class="pln"> </span><span class="str"><span class="hljs-string">'544ce385aeaeb5931556c6f9'</span></span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="pun">]</span><span class="pln"> </span><span class="pun">}</span></code></pre><h3>知识点</h3>
             <ol>
               <li>如何获取 accessToken？
                 用户登录后，在设置页面可以看到自己的 accessToken。
                 建议各移动端应用使用手机扫码的形式登录，验证使用 <code>/accesstoken</code> 接口，登录后长期保存 accessToken。</li>
             </ol>
           </div>
         </div>
       </div>
     </div>
   </div>
 </div>
</template>

<script>
export default {
  name: 'Api'
}
</script>

<style scoped>

</style>
